package demo2;

import demo1.OuterClass1;

public class OuterClass2 {
    public int data1 = 1;
    private int data2 = 2;
    public static final int data3 = 3;

    public void test(){
        System.out.println("外部类的test方法被执行了...");
    }

    //静态内部类
    static class InterClass2{
        public int data4 = 4;
        private int data5 = 5;
        public static final int data6 = 6;

        public void test(){
            System.out.println("静态内部类的test方法被执行了...");

            //访问外部类非静态成员 需要实例化外部类 再通过外部类的引用
            OuterClass2 outerClass2 = new OuterClass2();
            System.out.println(outerClass2.data1);
            System.out.println(outerClass2.data2);
            //System.out.println(data1);
            //System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }

    }

}
